package org.congapps.employees.model;

import java.util.Date;

import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import static javax.persistence.TemporalType.DATE;

@Embeddable
public class SalaryId implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private int empNo;
	private Date fromDate;

	public SalaryId() {
	}

	public SalaryId(int empNo, Date fromDate) {
		this.empNo = empNo;
		this.fromDate = fromDate;
	}

	public int getEmpNo() {
		return this.empNo;
	}

	public void setEmpNo(int empNo) {
		this.empNo = empNo;
	}

	@Temporal(DATE)
	public Date getFromDate() {
		return this.fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof SalaryId))
			return false;
		SalaryId castOther = (SalaryId) other;

		return (this.getEmpNo() == castOther.getEmpNo())
				&& ((this.getFromDate() == castOther.getFromDate()) || (this
						.getFromDate() != null
						&& castOther.getFromDate() != null && this
						.getFromDate().equals(castOther.getFromDate())));
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result + this.getEmpNo();
		result = 37 * result
				+ (getFromDate() == null ? 0 : this.getFromDate().hashCode());
		return result;
	}

}
